package com.hht.wblib.ist;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.hht.wblib.bean.ConfigurationBean;
import com.hht.wblib.listener.WhiteBoardImp;
import com.hht.wblib.utils.IntentHelps;

import java.io.File;

/**
 * Author:chen'hu
 * Time:2025/1/2 11:34
 * Description:This is IstWhiteBoard
 */
public class IstWhiteBoard extends WhiteBoardImp {

    public IstWhiteBoard(Context context, ConfigurationBean configurationBean) {
        super(context, configurationBean);
    }

    @Override
    public boolean sendPicturesToWhiteBoard(File file) {
        return IntentHelps.getInstance(mContext).setIntentConfigurator(intent -> {
            intent.setClassName(whiteBoardBean.getPkgName(), whiteBoardBean.getClassName());
            if (null != file && !TextUtils.isEmpty(file.getPath())) {
                intent.putExtra(whiteBoardBean.getPutKey(), file.getPath());
                intent.putExtra("position", new int[]{960, 540});
            }
        }).startActivity();
    }

    @Override
    public boolean openWhiteBoard() {
        return IntentHelps.getInstance(mContext).setIntentConfigurator(intent -> {
            intent.setComponent(new ComponentName(whiteBoardBean.getPkgName(),
                    whiteBoardBean.getClassName()));
        }).startActivity();
    }

    @Override
    public boolean openAnnotation() {
        return IntentHelps.getInstance(mContext).setIntentConfigurator(intent -> {
            intent.setAction(annotationBean.getAction());
            intent.setPackage(annotationBean.getPkgName());
            intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
            intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        }).sendBroadCast();
    }
}
